home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / cshx86.zip / SAMPLES / FACTOR.CSH < prev    next >
Text File  |  1993-04-14  |  304b  |  17 lines

  1. #    Calculate the prime factors of an integer.
  2. #    Copyright (c) 1989 by Hamilton Laboratories.  All rights reserved.
  3.         
  4. proc factor(n)
  5.     if (n > 3) then
  6.         for i = 2 to floor(sqrt(n)) do
  7.             if (n % i == 0) then
  8.                 echo $i
  9.                 return factor(n//i)
  10.             end
  11.         end
  12.     end
  13.     return n
  14. end
  15.  
  16. factor $argv
  17.